/*************************************************************************
 * File Name:    PascalsTriangleII.cc
 * Author:       zero91
 * Mail:         jianzhang9102@gmail.com
 * Created Time: Sat 21 Sep 2013 04:28:35 PM CST
 * 
 * Description:  
 *
 | ---------------------------------------------------------------------
 | Pascal's Triangle II
 |
 | Given an index k, return the kth row of the Pascal's triangle.
 |
 | For example, given k = 3,
 | Return [1,3,3,1].
 |
 | Note:
 | Could you optimize your algorithm to use only O(k) extra space?
 | ---------------------------------------------------------------------
 ************************************************************************/

#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    vector<int> getRow(int rowIndex)
    {
        vector<int> ans(rowIndex + 1);

        ans[0] = 1;
        for (int i = 1; i <= rowIndex; ++i) {
            ans[i] = int((long long)ans[i - 1] * (rowIndex - i + 1) / i);
        }
        return ans;
    }

    vector<int> getRow2(int rowIndex)
    {
        vector<int> ans(1,1);;
        
        for (int i = 1; i < rowIndex + 1; ++i) {
            for (int j = i - 1; j >= 1; --j) {
                ans[j] += ans[j - 1];
            }
            ans.push_back(1);
        }
        return ans;
    }

};

int
main(int argc, char *argv[])
{
    Solution sol;
    vector<int> ans;
    int n;

    while (cin >> n) {
        ans = sol.getRow(n);
        for (size_t i = 0; i < ans.size(); ++i) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }

    return 0;
}
